/*
 * Created on Sep 9, 2003
 *
 * UserGroup
 * Local Projects Database
 * (comparator) 2003 eRomania Gateway Association
 *
 */
package ro.gateway.aida.usr;

import java.util.Comparator;
import java.util.SortedSet;
import java.util.TreeSet;



/**
 * @author Mihai Postelnicu
 *
 * UserGroup
 * Local Projects Database
 * (comparator) 2003 eRomania Gateway Association
 * Each group has an id, a
 * UserGroup Vectors are initialized at server startup. Adding more groups
 * will also produce an object refresh. The groups can be accessd using
 * the PermissioningService object instatiated at startup
 *
 */
public class UserGroup
{
      protected int id;
      protected TreeSet superGroups;
      protected String name;
      protected String description;
      protected GroupRole role;

      /*the groups connected here with greater permissions that
      // this group have also
      access to items owned by the users assigned in this grup:*/
      public UserGroup()
      {
            superGroups = new TreeSet( new UserGroupComparator() );
      }


      /**
       * @return
       */
      public String getDescription()
      {
            return description;
      }

      /**
       * @return
       */
      public int getId()
      {
            return id;
      }

      /**
       * @return
       */
      public String getName()
      {
            return name;
      }

      /**
       * @param string
       */
      public void setDescription( String string )
      {
            description = string;
      }

      /**
       * @param i
       */
      public void setId( int i )
      {
            id = i;
      }

      /**
       * @param string
       */
      public void setName( String string )
      {
            name = string;
      }

      /**
       * @return
       */
      public SortedSet getSuperGroups()
      {
            return superGroups;
      }

      /**
       * @param list
       */
      public void setSuperGroups( TreeSet list )
      {
            superGroups = list;
      }

      /**
       * @return
       */
      public GroupRole getRole()
      {
            return role;
      }

      /**
       * @param role
       */
      public void setRole( GroupRole role )
      {
            this.role = role;
      }

      public static class UserGroupComparator implements Comparator
      {
            public int compare( Object o1, Object o2 )
            {
                  UserGroup u1 = ( UserGroup ) o1;
                  UserGroup u2 = ( UserGroup ) o2;

                  return ( u1.getId() - u2.getId() );
            }
      }
}
